Skip to content

Conversation

TonyKim9401
Copy link
Contributor

@TonyKim9401 TonyKim9401 commented Aug 25, 2024

체크 리스트

  • PR을 프로젝트에 추가하고 Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 Status를 In Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@TonyKim9401 TonyKim9401 marked this pull request as ready for review August 28, 2024 05:31
@TonyKim9401 TonyKim9401 requested a review from a team as a code owner August 28, 2024 05:31
Comment on lines +7 to +8
if (n >= 1) dp[1] = 1;
if (n >= 2) dp[2] = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n 이 1 또는 2 일 때는 아래 반복문을 수행하지 않아서 if 조건이 없어도 될 것 같아요!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 지금 보니 인덱스 처리때문에 추가하신 거군요
그럼에도 문제에서 n 은 1 이상이라고 했으니, if 조건은 2에만 있어도 될 것 같네요!

Comment on lines +3 to +4
// time complexity: O(n);
// space complexity: O(n);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(사소) Python 에서는 주석을 메서드 내부에 쓰긴 하나, Java 에서는 이렇게 작성하는 건 많이 보지 못했습니다 (물론 주석 바로 아래 코드에 대해 주석이 필요할 때는 작성하겠지만 요건 그 경우는 아닌 것 같군요 ㅎㅎㅎ) 주석을 메서드 또는 클래스 위로 옮겨주시면 어떨까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bky373 다음주부터 적용하도록 하겠습니다 감사합니다!

// time complexity: O(n);
// space complexity: O(n);
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < nums.length; i++) map.put(nums[i], i);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

시간 복잡도는 동일하지만 for 문을 한 번 사용하는 것으로 문제를 해결할 수 있습니다!
코드를 바꿔달라고 말씀드리는 건 아니고 나중에 시간되실 때 확인 한 번 해보시면 좋을 것 같습니다~

Copy link
Member

@DaleSeo DaleSeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

답안 코드 일찍 제출해주셔서 감사합니다. 승인 여부에 지장을 주지 않는 한 가지 질문을 남겼습니다.

@@ -0,0 +1,23 @@
class Solution {
// time complexity: O(2^n);
// space complecity: O(n*m);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어떻게 공간 복잡도가 O(n * m)이 나오셨는지 궁금합니다!

Copy link
Contributor

@taekwon-dev taekwon-dev Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어떻게 공간 복잡도가 O(n * m)이 나오셨는지 궁금합니다!

(공간 복잡도에 더해 ㅎㅎ..) 재귀가 사용 됐을 때 시간 복잡도를 어떻게 판단하시는지 과정이 궁금합니다..!

Copy link
Contributor Author

@TonyKim9401 TonyKim9401 Aug 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaleSeo @taekwon-dev 정정하겠습니다!
시간 복잡도: O(2^n * m)

  • 같은 숫자 반속 가능성과 주어진 배열의 길이

공간 복잡도: O(n * m)

  • 가능한 조합의 수와 가능한 조합의 길이

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TonyKim9401 저는 공간 복잡도에서 의문을 제기했는데, 시간 복잡도를 정정해주셨네요 ㅋㅋ 😵

Copy link
Contributor

@bky373 bky373 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생 하셨습니다!

@TonyKim9401 TonyKim9401 merged commit a724a34 into DaleStudy:main Aug 31, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

4 participants